#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from Lib import Exec, Network
import re

def checkRemoteHost(host, type=None):
    '''
    Check if a host is alive and if if you can connect to
    '''
    if not re.search("^\d*\.\d*\.\d*\.\d*$", host):
        dnsStatus = Network.checkLocalDNS()
        if dnsStatus[0] != 0:
            return(dnsStatus)
    aliveResult = Network.checkAlive(host)
    if aliveStatus != 0:
        return(aliveStatus)
    return(Errors.Err(0))

def checkRemoteFile(remote_file):
    '''
    Check if a remote file exists and is accessible
    If it exists, it returns a new file name with incremental counter at the end
    (eg. filename.tar.gz already exists. -> filename_2.tar.gz)
    '''
    resultingEntry = checkEntry(remote_file)
    prefix = re.sub("://.*", "", remote_file)
    suffix = re.sub(".*://", "", remote_file)
    
    

def checkRemoteDirectory(host, type=None, remote_directory):
    pass